package com.example.articletext.controller;

import com.example.articletext.entity.Article;
import com.example.articletext.service.ArticleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;

import java.util.List;

@Controller
public class ArticleController {

    @Autowired
    private ArticleService articleService;


    @GetMapping("/article")
    public String article(Model model){

        List<Article> articleList = articleService.findAll();
        model.addAttribute("articles",articleList);

        return "article";
    }
}
